/*
 * IRobotController.java
 *
 * Created on April 25, 2008, 1:01 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.ncsu.robowulf;

import com.sun.spot.core.peripheral.IDriver;
import com.sun.spot.core.resources.ResourceUnavailableException;

/**
 * An interface for dealing with SPOT-driven robots
 * Since deep sleep causes the pulses to Servos to stop, remember to report inability to deep sleep in IDriver.tearDown
 * when servos are active.
 * @author Douglas McClusky
 */
public interface IRobotController extends IDriver {
    
    /**
     * Go forward
     * @param the number of units to go.  Units supported should be documented by the implementing class.
     */
    public abstract void forward(double units);
    
    /**
     * Go backward
     * @param the number of units to go.  Units supported should be documented by the implementing class.
     */
    public abstract void backward(double units);
    
    /**
     * Go left
     * @param the number of units to go.  Units supported should be documented by the implementing class.
     */
    public abstract void left(double units);
    
    /**
     * Go right
     * @param the number of units to go.  Units supported should be documented by the implementing class.
     */
    public abstract void right(double units);
    
    /**
     * Engage the servos to hold the robot still
     * @param the length of time to remain engaged.  Units supported should be documented by the implementing class.
     */
    public abstract void brake(long units);
    
    public abstract void stop();
    
    /**
     * Set the units used for movement
     * @param the type of units to use.  Units supported should be documented by the implementing class.
     */
    public abstract void setUnits(int units);
    
    /**
     * Read the designated IRobotSensor
     * IRobotControllers should publish which sensors they are supporting and to which pins these should be connected.
     * @return the IRobotSensor's converted value
     * @throws ResourceUnavailableException if the index is not supported or if the IRobotSensor cannot be detected.
     */
    public double senseFrom(int index) throws ResourceUnavailableException;
    
}
